package besta.moon.command;

import besta.moon.MoonConnection;
import besta.moon.statement.MoonStatement;
import besta.moon.MoonLogger;
import besta.moon.MoonCommand;
import besta.moon.sql.parser.SQLTokenizer;

public class CommandSet extends MoonCommand {

    public int isolationLevel;

    public CommandSet(MoonLogger log, int type) {
        super(log);
        this.type = type;
    }

    @Override
    public void executeImpl(MoonConnection con, MoonStatement st) throws java.sql.SQLException {
        switch (type) {
            case SQLTokenizer.LEVEL:
                con.isolationLevel = isolationLevel;
                break;
            case SQLTokenizer.USE:
                con.setCatalog(name);
                break;
            default:
                throw new Error();
        }
    }
}
